package wiki.kaizen.cloud.plugin.spring.deserializer;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.serializer.StringCodec;

import java.lang.reflect.Type;
/**
 * String 类反序列化,遇到空字符串"" 返回null
 * @author Kaizen
 * */
public class StringDeserializer extends StringCodec {
    @Override
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
        T value = super.deserialze(parser, clazz, fieldName);
        return (value instanceof  String && "".equals(value))?null:value;
    }
}
